package com.oa.lms.apps.business.absence.impl;

import java.util.List;

import com.oa.lms.apps.business.absence.IAbsenceCategoryService;
import com.oa.lms.apps.constants.IDEDStatus;
import com.oa.lms.apps.dao.absence.IAbsenceCategoryDao;
import com.oa.lms.apps.entity.absence.AbsenceCategoryValue;

public class AbsenceCategoryServiceImpl implements IAbsenceCategoryService {

	private IAbsenceCategoryDao absenceCategoryDao;
	
	private AbsenceCategoryValue absenceCategoryValue;
	@Override
	public Integer add(String categoryName) {
		absenceCategoryValue.setCategoryName(categoryName);
		absenceCategoryValue.setStatus(IDEDStatus.ENABLE);
		return absenceCategoryDao.add(absenceCategoryValue);
	}

	@Override
	public void modify(Integer categoryId, String categoryName) {
		absenceCategoryValue = this.queryByCategoryId(categoryId);
		absenceCategoryValue.setCategoryName(categoryName);
		absenceCategoryDao.modify(absenceCategoryValue);

	}

	@Override
	public void delete(Integer categoryId) {
		absenceCategoryValue = this.queryByCategoryId(categoryId);
		absenceCategoryValue.setStatus(IDEDStatus.DELETE);
		absenceCategoryDao.modify(absenceCategoryValue);

	}

	@Override
	public void toDisable(Integer categoryId) {
		absenceCategoryValue = this.queryByCategoryId(categoryId);
		absenceCategoryValue.setStatus(IDEDStatus.DISABLE);
		absenceCategoryDao.modify(absenceCategoryValue);

	}

	@Override
	public void toEnable(Integer categoryId) {
		absenceCategoryValue = this.queryByCategoryId(categoryId);
		absenceCategoryValue.setStatus(IDEDStatus.ENABLE);
		absenceCategoryDao.modify(absenceCategoryValue);

	}

	@Override
	public AbsenceCategoryValue queryByCategoryId(Integer categoryId) {
		return absenceCategoryDao.queryByCategoryId(categoryId);
	}

	@Override
	public List<AbsenceCategoryValue> queryAbsenceCategory(String categoryName,
			Integer status) {
		if(categoryName != null)
			absenceCategoryValue.setCategoryName(categoryName);
		if(status != null)
			absenceCategoryValue.setStatus(status);
		return absenceCategoryDao.queryAbsenceCategory(absenceCategoryValue);
	
	}
	
	//Getter and Setter

	public IAbsenceCategoryDao getAbsenceCategoryDao() {
		return absenceCategoryDao;
	}

	public void setAbsenceCategoryDao(IAbsenceCategoryDao absenceCategoryDao) {
		this.absenceCategoryDao = absenceCategoryDao;
	}

	public AbsenceCategoryValue getAbsenceCategoryValue() {
		return absenceCategoryValue;
	}

	public void setAbsenceCategoryValue(AbsenceCategoryValue absenceCategoryValue) {
		this.absenceCategoryValue = absenceCategoryValue;
	}

	
}
